using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MAPDavy.Entities;

namespace MAPDavy.Repository.Mapping
{
	public class ScoreMap : EntityTypeConfiguration<Score>
	{
		public ScoreMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("Score");
			this.Property(t => t.Id).HasColumnName("Id");			
			this.Property(t => t.TestGradeId).HasColumnName("TestGradeId");
			this.Property(t => t.MatriculaId).HasColumnName("MatriculaId");
			this.Property(t => t.RIT).HasColumnName("RIT");
			this.Property(t => t.Locket).HasColumnName("Locket");
			this.Property(t => t.DateTest).HasColumnName("DateTest");
            this.Property(t => t.ColorCodeId).HasColumnName("ColorCodeId");

			// Relationships
            this.HasOptional(t => t.ColorCode)
                .WithMany(t => t.Scores)
                .HasForeignKey(d => d.ColorCodeId);

			this.HasRequired(t => t.Matricula)
				.WithMany(t => t.Scores)
				.HasForeignKey(d => d.MatriculaId);
							
			this.HasRequired(t => t.TestGrade)
				.WithMany(t => t.Scores)
				.HasForeignKey(d => d.TestGradeId);
				
		}
	}
}

